﻿package mortal.game.scene3D.display3d.text3d.dynamicText3d
{
    import __AS3__.vec.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.filters.vertexFilters.*;
    import frEngine.shader.filters.vertexFilters.def.*;

    public class Text3DVertexFilter extends VertexFilter
    {
        public var text3dConst:Vector.<Number>;

        public function Text3DVertexFilter()
        {
            this.text3dConst = this.Vector.<Number>([1, 256, -1, 128]);
            super(-1, null);
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            return;
        }// end function

        override public function get programeId() : String
        {
            return "textVertexFilter0";
        }// end function

        override public function createVertexCode(param1:Program3dRegisterInstance, param2:int) : String
        {
            var _loc_3:Array = [];
            _loc_3.push(new ToBuilderInfo("vc0-100", "{textPosList}", false, 100, []));
            _loc_3.push(new ToBuilderInfo("vc1", "{textConst}", false, 1, this.text3dConst));
            _loc_3.push(new ToBuilderInfo("va0", FilterName.POSITION, false, 3));
            _loc_3.push(new ToBuilderInfo("va1", FilterName.SKIN_INDICES, false, 1));
            _loc_3.push(new ToBuilderInfo("vf0", "{v_textRate}", false, 1));
            var _loc_4:String = "";
            _loc_4 = _loc_4 + "mov           vt0    \t\t\t\tvc[va1.x]  \t\t\t\t\t\n";
            _loc_4 = _loc_4 + "sub         \t {output}.x      \t\tvt0.x\t\t\t\t{viewPortRect}.z\t\t\n";
            _loc_4 = _loc_4 + "sub         \t {output}.y      \t\t{viewPortRect}.w\tvt0.y\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "mul         \t {output}.xy      \t{output}.xy\t   \tvc1.x\t\t\t\n";
            _loc_4 = _loc_4 + "frc         \t vt1.xy      \t\t\t{output}.xy\t   \t\t\t\t\t\n";
            _loc_4 = _loc_4 + "sub         \t {output}.xy      \t{output}.xy\t   \tvt1.xy\t\t\t\n";
            _loc_4 = _loc_4 + "mul           vt2.y    \t\t\tva0.y  \t\t\tvt0.w\t\t\t\t\n";
            _loc_4 = _loc_4 + "mul           vt2.x    \t\t\tva0.x  \t\t\tvc1.w\t\t\t\t\n";
            _loc_4 = _loc_4 + "add           {output}.x    \t\t{output}.x         \t\tvt2.x  \t\n";
            _loc_4 = _loc_4 + "add           {output}.y    \t\t{output}.y         \t\tvt2.y  \t\n";
            _loc_4 = _loc_4 + "div         \t {output}.xy      \t{output}.xy\t   {viewPortRect}.xy\t\n";
            _loc_4 = _loc_4 + "mul         \t {output}.xy      \t{output}.xy\t   {vcConst1}.w\t\t\n";
            _loc_4 = _loc_4 + "mov         \t {output}.zw      \t{vcConst1}.xxxz\t   \t\t\t\t\t\n";
            _loc_4 = _loc_4 + "sge           vt1.z    \t\t\tvt0.w  \t\t\t\t{vcConst1}.x\t\t\n";
            _loc_4 = _loc_4 + "mul           {output}.xy    \t\t{output}.xy    \tvt1.z  \t\t\t\t\n";
            _loc_4 = _loc_4 + "frc         \t vt1.w      \t\t\tvt0.z\t   \t\t\t\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "sub         \t vt0.z      \t\t\tvt0.z\t   \t\t\tvt1.w\t\t\t\t\n";
            _loc_4 = _loc_4 + "div           vt1.xy\t\t\t\tvt0.wz      \t\tvc1.yy\t\t\t\t\n";
            _loc_4 = _loc_4 + "mov           vf0    \t\t\t\tvt1  \t\t\t\t\t\t\t\t\t\n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            param1.OpType = ECalculateOpType.None;
            return _loc_4;
        }// end function

    }
}
